$(function(){
	$("#btnCreate").click(function(){
		var vendor = $("#Name").val();
		var vendorAddress = $("#Address").val();
		var vendorPhone = $("#Phone").val();
		var vendorFax = $("#FAX").val();
		var contactPerson = $("#Contact").val();
		$.ajax({
			type:"POST",
			url:"SystemConfig",
			dataType:"json",
			contentType:"application/x-www-form-urlencoded; charset=utf-8",
			async:false,
			data:"method=5&vendor="+vendor+"&vendorAddress="+vendorAddress+"&vendorPhone="+vendorPhone+"&vendorFax="+vendorFax+"&contactPerson="+contactPerson,
			success:function(data){
				location.reload();
				alert("添加成功");
			},
			error:function(){
				alert("添加失败");
			}
		});
		
	});
	
	$("#btnReset").click(function(){
		$("#Name").val("");
		$("#Address").val("");
		$("#Phone").val("");
		$("#FAX").val("");
		$("#Contact").val("");
	});
});

$(function(){
	$(".alterSupplier").click(function(){
		var supplierId = $(this).parent().prev().prev().prev().prev().prev().attr("supplierId");
		$("#Name1").val($(this).parent().prev().prev().prev().prev().prev().html());
		$("#Address1").val($(this).parent().prev().prev().prev().prev().html());
		$("#Phone1").val($(this).parent().prev().prev().prev().html());
		$("#FAX1").val($(this).parent().prev().prev().html());
		$("#Contact1").val($(this).parent().prev().html());
		
		$("#btnCreate1").click(function(){
			var vendor = $("#Name1").val();
			var vendorAddress = $("#Address1").val();
			var vendorPhone = $("#Phone1").val();
			var vendorFax = $("#FAX1").val();
			var contactPerson = $("#Contact1").val();
			$.ajax({
				type:"POST",
				url:"SystemConfig",
				dataType:"json",
				contentType:"application/x-www-form-urlencoded; charset=utf-8",
				async:false,
				data:"method=6&vendor="+vendor+"&vendorAddress="+vendorAddress+"&vendorPhone="+vendorPhone+"&vendorFax="+vendorFax+"&contactPerson="+contactPerson+"&supplierId="+supplierId,
				success:function(data){
					location.reload();
					alert("修改成功");
				},
				error:function(){
					alert("修改失败");
				}
			});
		});
	});
	$("#btnReset1").click(function(){
		$("#Name1").val("");
		$("#Address1").val("");
		$("#Phone1").val("");
		$("#FAX1").val("");
		$("#Contact1").val("");
	});
});
